using System.Collections.Generic;
using System.Text;
using System;
using NHibernate;
using NHibernate.Cfg;
using JVLMRP;
namespace JVLMRP 
{
    class MRPOrderTypesService 
    {
        ISession session;

        public MRPOrderTypesService( )
        {
            this.session = SessionFactory.GetNewSession();
        }

        public void InsertMrpordertypes(MRPOrderTypes mrpordertypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Save(mrpordertypesX);
            tx.Commit();
        }

        public void UpdateMrpordertypes(MRPOrderTypes mrpordertypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Update(mrpordertypesX);
            tx.Commit();
        }

        public void DeleteMrpordertypes(MRPOrderTypes mrpordertypesX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Delete(mrpordertypesX);
            tx.Commit();
        }

        public IList<MRPOrderTypes> GetAllMrpordertypes(Boolean evict)
        {
            IQuery query = session.CreateQuery("select from MRPOrderTypes");
            IList<MRPOrderTypes> list = query.List<MRPOrderTypes>();
            if (evict)
            {
                foreach (MRPOrderTypes s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }

        public MRPOrderTypes GetAllMrpordertypesByID(String id,Boolean evict)
        {
            IQuery query = session.CreateQuery("select c from MRPOrderTypes as c where c.Ordertypecode= :x");
            query.SetString("x", id);
            MRPOrderTypes s = (MRPOrderTypes)query.UniqueResult();
            if (evict)
            {
                session.Evict(s);
            }
            return s;
        }

        public IList<MRPOrderTypes> GetMrpordertypesByQuery(IQuery query,Boolean evict)
        {
            IList<MRPOrderTypes> list = query.List<MRPOrderTypes>();
            if (evict)
            {
                foreach (MRPOrderTypes s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }


    }
}
